package ctrl;

import entities.Room;
import hotel.jpa.Database;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 * A class to controll the data 
 * @author Anton Karlsson
 */
@ManagedBean(name = "pickRoomControllerBean")
@SessionScoped
public class PickRoomControllerBean {
    
    protected Room room;

    public Room getRoom() {
        return room;
    }
    
    public void setRoom(Room r){
        this.room = r;
    }

    public String add(Long id) {
     
        //Product p = (Product) productCtrl.findEntity(id);
        List<Room> ps = Database.getRoomController().findEntities();
        Room p = null;
        for (Room pr : ps) {
            if (pr.getId() == id) {
                p = pr;
            }
        }

        room = new Room(p.getRoomNb(), p.getBathRoom(),  p.getKitchen(), p.getPrice(), p.getRoomType());
               
        return "/user/pickRoom.xhtml";
    }
}
